<template>
  <div class="home">
    <h3>
      HOME -- {{ $store.state.zhangsan.name }}
    </h3>
    <h4>
      计算属性 -- {{ $store.getters["zhangsan/newName"] }}
    </h4>
    <button @click="changeName">点我修改</button>
    <div>
      <button @click="initAsync">发起异步</button>
    </div>
  </div>
</template>

<script>

export default {
  name: 'Home',
  created() {
    console.log(this.$store)
  },
  methods: {
    changeName() {
      this.$store.commit("zhangsan/CHANGE_NAME")
    },
    initAsync() {
      this.$store.dispatch("zhangsan/init")
    }
  }
}
</script>
